
import React from 'react';
import PropTypes from 'prop-types';
import {injectIntl} from './intl';
import {Card, Row, Col} from 'antd';
import {conventEnumValueToString, formatAmount} from '../utils';
import {baseDataStatus, currency} from '../Enum';
import DescriptionList from 'ant-design-pro/lib/DescriptionList';
const {Description} = DescriptionList;
import styles from './style.css';
/* eslint-disable react/prefer-stateless-function */
class Detail extends React.PureComponent {
    render() {
        return (
            <div>
                <Card>
                    <DescriptionList size="large" title={<Row><Col span={6}>{this.props.intl.formatMessage({
                        id: 'commonDetail.order.title',
                        defaultMessage: '地产件信息'
                    })}</Col>
                    <Col className={styles.optionBtn} span={18}>{this.props.operations}</Col></Row>}>
                        <Description
                            term={this.props.intl.formatMessage({
                                id: 'commonDetail.info.brandCode',
                                defaultMessage: '品牌编号'
                            })}>
                            {this.props.detail.brandCode}
                        </Description>
                        {this.props.isDealerUser ? null : <Description
                            term={this.props.intl.formatMessage({
                                id: 'commonDetail.info.dealerCode',
                                defaultMessage: '总代编号'
                            })}>
                            {this.props.detail.dealerCode}
                        </Description>}
                        <Description
                            term={this.props.intl.formatMessage({
                                id: 'commonDetail.info.localCode',
                                defaultMessage: '地产件编号'
                            })}>
                            {this.props.detail.localCode}
                        </Description>
                        <Description
                            term={this.props.intl.formatMessage({
                                id: 'commonDetail.info.localName',
                                defaultMessage: '地产件名称'
                            })}>
                            {this.props.detail.localName}
                        </Description>
                        <Description
                            term={this.props.intl.formatMessage({
                                id: 'commonDetail.info.minPackSize',
                                defaultMessage: '最小包装数'
                            })}>
                            {this.props.detail.minPackSize}
                        </Description>
                        <Description
                            term={this.props.intl.formatMessage({
                                id: 'commonDetail.info.partReplacementCode',
                                defaultMessage: '替换件编号'
                            })}>
                            {this.props.detail.partReplacementCode}
                        </Description>
                        <Description
                            term={this.props.intl.formatMessage({
                                id: 'commonDetail.info.currency',
                                defaultMessage: '币种'
                            })}>
                            {conventEnumValueToString(currency, this.props.detail.currency)}
                        </Description>
                        <Description
                            term={this.props.intl.formatMessage({
                                id: 'commonDetail.info.price',
                                defaultMessage: '单价'
                            })}>
                            {formatAmount(this.props.detail.price)}
                        </Description>
                        <Description
                            term={this.props.intl.formatMessage({
                                id: 'commonDetail.info.manufactory',
                                defaultMessage: '工厂'
                            })}>
                            {this.props.detail.manufactory}
                        </Description>
                        <Description
                            term={this.props.intl.formatMessage({
                                id: 'commonDetail.info.status',
                                defaultMessage: '状态'
                            })}>
                            {conventEnumValueToString(baseDataStatus, this.props.detail.status)}
                        </Description>
                        <Description
                            term={this.props.intl.formatMessage({
                                id: 'commonDetail.info.remark',
                                defaultMessage: '备注'
                            })}>
                            {this.props.detail.remark}
                        </Description>
                        <Description
                            term={this.props.intl.formatMessage({
                                id: 'commonDetail.info.productCategoryCode',
                                defaultMessage: '车型'
                            })}>
                            {this.props.detail.productCategoryCode}
                        </Description>
                    </DescriptionList>
                </Card>
            </div>
        );
    }
}

Detail.defaultProps = {
    detail: {},
    isDealerUser: true
};

Detail.propTypes = {
    detail: PropTypes.object,
    intl: PropTypes.object,
    isDealerUser: PropTypes.bool,
    operations: PropTypes.any,
};
export default injectIntl(Detail);
